%% Example of Vector operations and error handling

%Make two vectors
A=[1 0 0]
B=[0 1 0]

%or these
A=rand(3,1)
B=rand(3,1)

%Use my cross product function
%Note: We are using this as an example for error handling inside
%a function. 
[ C ] = mycross(A,B)

%Compare to MATLAB cross product. 
cross(A,B)

%Try some things that should not work:

%Vector too short:
B=rand(2,1)
[ C ] = mycross(A,B)

%Vector too long:
B=rand(4,1)
[ C ] = mycross(A,B)

%Give wrong number of input arguments
[ C ] = mycross(A)



%% Matrix operations 

%Make two vectors. 
A=rand(1,3)
B=rand(3,1)

%this is dot-product (aka inner product)
A*B

%The Identity matrix
eye(2)

%This solves the following system of equations:

% x+5y=10
%
% 2x+y=3

%We can write this as:

% A*x=b

% so:

% inv(A)*A*x=inv(A)*b

% x=inv(A)*b


%Build A and b
A=[1,5;2,1]
b=[10;3]

%Check Rank
rank(A)

%Find x
x=inv(A)*b

%Check answer. 
A*x
b



















